package com.wechat.api.config;

import com.wechat.api.service.WeChatApi;
import com.wechat.api.service.impl.WeChatApiImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@EnableConfigurationProperties(WeChatConfigProperties.class)
@Configuration
public class WeChatAutoConfiguration {

    @Autowired
    private WeChatConfigProperties properties;

    @Bean
    @ConditionalOnMissingBean
    public WeChatApi weChatApiService(){
        return new WeChatApiImpl(properties);
    }
}
